var express = require('express');
var router = express.Router();

var auth = function(req, res, next) {
	if (req.session.auth) {
		return next();
	}
	req.session.originalUrl = req.originalUrl ? req.originalUrl : null;
	req.flash('message', '请先登录!');
	res.redirect('/login');
}

router.all('/*', auth);

router.get('/post/create', function(req, res) {
	res.render('post-create', {
		title: 'hehe'
	});
});

module.exports = router;